//this file is the config file and the struct core_conf is for init in core
#ifndef CORE_CONF_H
#define CORE_CONF_H

#include<pcap.h>
#include<stdio.h>
#include"node_conf.h"
#include<stdlib.h>
#include"log.h"
#include<sys/socket.h>
#include<sys/types.h>
#include<sys/un.h>

#define DB_CONFIGURE_MAX_LEN 512
#define DB_SUPPORT_MAX_NUM 8


struct core_conf
{
	char *core_conf_file;
	int pcap_mode;
	char *pcap_file;
	char *pcap_interface;
	pcap_t *pcap_handle;
	int pcap_datalink_type;


	unsigned long max_id;
	unsigned int mode;
	
	int usleep_time;

	int use_mm;
	unsigned long mm_limit;

	int use_mail;
	char *to;

	struct db_info *db_info;
	char db_config[DB_SUPPORT_MAX_NUM][DB_CONFIGURE_MAX_LEN];
	int db_count;

	int sock_fd;
	int sock_balance;
	
	char * node_file;	
	struct node_conf Node_conf;
	
	char * server_file;
	struct node server;
	struct sockaddr_in *local_addr;

	char * balance_file;
	struct node balance_server;
	struct sockaddr_in *balance_addr;	
};

enum core_conf_index {
	CORE_CONF_FILE = 0,

	PCAP_MODE = 1,
	PCAP_FILE = 2,
	PCAP_INTERFACE = 3,

	USLEEP_TIME = 4,

	USE_MM = 5,
	MM_LIMIT = 6,

	MAX_ID = 7,
	MODE = 8,

	USE_MAIL = 9,
	TO = 10,

	DB_CONF = 11,

	NODE_FILE = 12,
	
	SERVER_FILE = 13,
	
	BALANCE_FILE = 14,

	END_OF_CORE_CONF_INDEX,
};


extern void core_conf_from_file(struct core_conf *Core_conf,char * file_name);

extern void core_conf_init_node(struct core_conf *Core_conf,char * file_name);

extern void core_conf_init_server(struct node *Node,char *file_name);
#endif
